function setCtx(ctx) {
	this.ctx = ctx;
	
}

function checkCommon(){
	var common = $("#common").val();
	if(common == null || common == ""){
		layer.tips('请填写评论!', '#common', {
			tips: 3,
			time:1000
		});
		return false;
	} else{
		return true;
	}
}

function showdelete(target){
	$(target).children("span").css("display","block");
}

function hidedelete(target){
	$(target).children("span").css("display","none");
}

//删除拍摄照片
function deletePic(){
	var imageId = $("#imageId").val();
	var infoId = $("#ID").val();
	$.post(ctx + "/propertySuggestion/deleteImage", {
		imageId:imageId 
		},
	function(data) {
		data = JSON.parse(data);
		if (data.success) {
			layer.msg("操作成功", {
				icon : 1,
				time : 1000
			// 2秒关闭（如果不配置，默认是3秒）
			}, function() {
				window.parent.gotoShowDetails(infoId);
				parent.layer.close(index); // 根据窗口索引关闭窗口

			});
		} else {
			layer.msg(data.msg, {
				icon : 2,
				time : 1000
			// 2秒关闭（如果不配置，默认是3秒）
			}, function() {
				parent.layer.close(index); // 根据窗口索引关闭窗口
			});
		}
	});
}

function shutComplainAndCommon(id) {
	var common = $("#common").val();
	var replys = {};
	replys.content = common;
	replys.infoId = id;
	
	if (checkCommon()) {
		var index1 = layer.load(1);
		$.post(ctx +"/propertySuggestion/saveReply", replys,
			 function(data) {
			data = JSON.parse(data);
			if (data.success) {
				layer.msg("操作成功", {
					icon : 1,
					time : 1000
				// 2秒关闭（如果不配置，默认是3秒）
				}, function() {
					layer.close(index1);
					window.parent.gotoShowDetails(id);
					parent.layer.close(index); // 根据窗口索引关闭窗口
					
				});
			} else {
				layer.msg(data.msg, {
					icon : 2,
					time : 1000
				// 2秒关闭（如果不配置，默认是3秒）
				}, function() {
					layer.close(index1);
					parent.layer.close(index); // 根据窗口索引关闭窗口
				});
			}
		});
	}
}

function gotoShowDetails(id){
	$('#first').load(ctx+"/propertySuggestion/showDetails?id="+id);
}

function BackDetail(){
	parent.window.location.href = ctx + "/propertySuggestion/infoList";
}